package bitwise;

/**
 *
 * Fully Tested: No
 * Fully Documented: No
 * Created: 6-Mar-2012
 * Last Updated: 6-Mar-2012
 *
 * @author Shimu Wu
 */
public class BitwiseFunctions {
    
    private BitwiseFunctions(){
        
    }
    
    /**
     * Returns true iff the result of (bits1 AND bits2) has at least one 
     * bit that is set to 1.
     * 
     * @param bits1
     * @param bits2
     * @return 
     */
    public static boolean AND(int bits1, int bits2){
        return ((bits1 & bits2) == 1);
    }
    
    /**
     * Returns the result of using bitwise OR on the given integers. 
     * 
     * @param integers
     * @return 
     */
    public static int OR(int... integers) {
        int result = 0;
        for (int i : integers) {
            result = result | i;
        }
        return result;
    }
    
    /**
     * Returns the result of using bitwise AND on the given integers. 
     * 
     * @param integers
     * @return 
     */
    public static int AND(int... integers) {
        int result = 0;
        for (int i : integers) {
            result = result & i;
        }
        return result;
    }
    
}
